package nl.windgazer.arachne.services.yql;

import org.apache.tapestry5.json.JSONObject;

public class YQLGeoLocation implements YQLLocation {

	private static int i = 0;

	private final String[] colors = new String[]{"blue","red","yellow","gray","black","white"};

	private final double latitude;

	private final double longitude;

	private final String name;

	private String color;

	public YQLGeoLocation(JSONObject l) {
		final JSONObject c = l.getJSONObject("centroid");
		latitude = c.getDouble("latitude");
		longitude = c.getDouble("longitude");
		name = l.getString("name");
		if (i==colors.length)i=0; //reset :)
		setColor(colors[i++]);
	}

	public double getLatitude() {
		return latitude;
	}

	public double getLongitude() {
		return longitude;
	}

	public String getName() {
		return name;
	}

	public void setColor(String color) {
		this.color = color;
	}

	public String getColor() {
		return color;
	}

}
